import wx,os
from threading import Thread
from xui.dm_window import DmWindow
from xui.win32_hand_biz import Win32HandBiz
from uibiz.jd_order_card import JdOrderCard


class WindowJdCard(object):
  def begin(this):
    dmWin = DmWindow("JD苹果ID提取")
    this.hand = Win32HandBiz()
    panelMain = wx.Panel(dmWin.frame)

    # ui.open
    btnOpen = wx.Button(panelMain, label="打开浏览器(Edge)", pos=(10, 10), size=(120, 30))
    btnOpen.Bind(wx.EVT_BUTTON, this.onClickOpenEdge)

    # ui.ok
    btnOk = wx.Button(panelMain, label="读取苹果ID", pos=(140, 10), size=(120, 30))
    btnOk.Bind(wx.EVT_BUTTON, this.onClickPhoneId)

    # ui.ordr-ls
    btnOk = wx.Button(panelMain, label="读取订单列表", pos=(280, 10), size=(120, 30))
    btnOk.Bind(wx.EVT_BUTTON, this.onClickOrderLs)

    

    # ui.log
    wx.StaticText(panelMain, label="日志", pos=(10, 45), size=(70, 20), style=wx.ALIGN_LEFT)
    this.inpLog = wx.TextCtrl(panelMain, pos=(10, 70), size=(400, 220), style = wx.TE_MULTILINE)

    dmWin.toShowWindow()
  # 读取苹果ID
  def onClickPhoneId(this, v2):
    jd = JdOrderCard()
    this.setTxt(jd.readIphoneId())
  # 读取订单列表
  def onClickOrderLs(this, v2):
    jd = JdOrderCard()
    this.setTxt(jd.readMyOrderLs())
  # 打开edge
  def onClickOpenEdge(this, v2):
    # os.system('start msedge.exe --remote-debugging-port=9222')
    os.system('start msedge.exe --force-renderer-accessibility')
  def log(this,txt):
    this.inpLog.AppendText("\n"+txt)
  def setTxt(this,txt):
    this.inpLog.Clear()
    this.inpLog.AppendText(txt)
    #this.inpLog.GetValue()
hello = WindowJdCard()
hello.begin()